package com.longxiao.vo;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * 老师排期表载体
 * Created by houhongwei on 2017/5/3.
 */
public class TchCell {

    // 编号
    private String id;
    // 描述
    private String intro;
    // 日期
    private String date;
    // true 表头 false 数据单元格
    private boolean isTitle = Boolean.FALSE;
    // 排期状态 0未匹配 1匹配成功
    private int scheduleStatus = 0;
    // 奖励CP数量  0不奖励
    private int rewardCp = 0;

    private int classId;

    // 服务器当前时间
    private String svrCurTime;
    // 用户取消所需要消耗的CP
    private int cancelCpNum;

    public TchCell(String id, String intro, String date, boolean isTitle, int scheduleStatus, int rewardCp, int classId, String svrCurTime, int cancelCpNum) throws ParseException {
        this.id = id;
        this.intro = intro;
        this.isTitle = isTitle;
        this.scheduleStatus = scheduleStatus;
        this.rewardCp = rewardCp;
        this.date = date;
        this.classId = classId;
        this.svrCurTime = svrCurTime;
        this.cancelCpNum = cancelCpNum;
    }

    public static TchCell createTchCell(Cell cell) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        SimpleDateFormat sdf_yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        TchCell tchCell = null;
        try {
            String tmpDate = "";
            if (cell.getDate() == null || "".equals(cell.getDate())) {
            } else {
                tmpDate = sdf.parse(cell.getDate() + " " + cell.getTime()).toGMTString();
            }
            String tmpSvrCurTime = "";
            if (cell.getSvrCurTime() != null && !"".equals(cell.getSvrCurTime())) {
                tmpSvrCurTime = sdf_yyyyMMddHHmmss.parse(cell.getSvrCurTime()).toGMTString();
            }

            tchCell = new TchCell(cell.getId(), cell.getIntro(), tmpDate, cell.getIsTitle(), cell.getScheduleStatus(), cell.getRewardCp(), cell.getClassId(), tmpSvrCurTime, cell.getCancelCpNum());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return tchCell;
    }

    public String getId() {
        return id;
    }

    public String getIntro() {
        return intro;
    }

    public String getDate() {
        return date;
    }

    public boolean getIsTitle() {
        return isTitle;
    }

    public int getScheduleStatus() {
        return scheduleStatus;
    }

    public int getRewardCp() {
        return rewardCp;
    }

    public int getClassId() {
		return classId;
	}

	public String getSvrCurTime() {
        return svrCurTime;
    }

    public int getCancelCpNum() {
        return cancelCpNum;
    }
}
